#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef int I;
typedef long long LL;
const I N = 3010;
I tc,cnt,b[N + N],n,m,L,V,dp[N],ar[N];
LL p[N];
struct car{
    LL d,v,a;
}a[N];
I ppc(const I &x){
    I tmp = x,cnt = 0;
    while(tmp){
        if(tmp & 1) cnt++;
        tmp >>= 1;
    }
    return cnt;
}
void solve(){
    scanf("%d%d%d%d",&n,&m,&L,&V);
    for(I i = 1;i <= n;i++){
        scanf("%lld%lld%lld",&a[i].d,&a[i].v,&a[i].a);
    }
    for(I i = 1;i <= m;i++){
        scanf("%lld",&p[i]);
    }
    sort(p + 1,p + n + 1);
    cnt = 0;
    for(I i = 1;i <= n;i++){
        I l = m + 1,r = 0;
        bool flag = false;
        for(I j = 1;j <= m;j++) if(p[j] >= a[i].d){
            LL k  = a[i].v * a[i].v + 2LL * a[i].a * (p[j] - a[i].d);
            if(k < 0) continue;
            if(k > V * V){
                flag = true;
                ar[j] |= (1 << (i - 1));
            }
        }
        if(flag){
            ++cnt;
        }
    }
    I ans = m + 1;
    for(I i = 0;i < (1 << m);i++){
        I res = 0;
        for(I j = 1;j <= m;j++) if((i >> (j - 1) & 1)){
            res |= ar[j];
        }
        if(ppc(res) == cnt){
            ans = min(ans,ppc(i));
        }
    }
    printf("%d %d\n",cnt,m - ans);
}
void Qingkong(){
    for(I i = 1;i <= m;i++){
        ar[i] = 0;
    }
}
I main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&tc);
    for(;tc--;){
        //puts("case:");
        solve();
        Qingkong();//duo ce bu qing kong bao ling liang hang lei
    }
    return 0;
}
